﻿@model LunchCommand.ViewModels.VenueViewModel

@{
    ViewBag.Title = "Edit";
}

<style>
    .btn {
        margin-right: 20px;
    }
</style>

@if (String.IsNullOrWhiteSpace(Model.Name))
{
    <h2>Add New Venue</h2>
}
else
{
    <h2>Edit @Model.Name</h2>
}


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true, "Please correct the issues below", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.VenueID)

        <div class="form-group">
            @Html.LabelFor(model => model.Name, "Venue Name", htmlAttributes: new { @class = "control-label col-md-3" })
            <div class="col-md-9">
                @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Address, "Address (optional)", htmlAttributes: new { @class = "control-label col-md-3" })
            <div class="col-md-9">
                @Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Address, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.GenreID, "Genre", htmlAttributes: new { @class = "control-label col-md-3" })
            <div class="col-md-9">
                @Html.DropDownList("GenreID", null, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.GenreID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.IsQuick, "Good for quick lunches", htmlAttributes: new { @class = "control-label col-md-3" })
            <div class="col-md-9" style="text-align: left">
                @Html.CheckBoxFor(model => model.IsQuick, htmlAttributes: new { @class = "form-control left", style = "width: 45px", onclick = "$('#special').prop('disabled', !this.checked)" })
            </div>
        </div>

        <div class="col-md-4"></div>
        <div class="col-md-8">
            <a href="#" onclick="$(this).hide(); $('.advanced.hidden-for-now').show()">Show Uncommon Options</a>
        </div>

        <div class="advanced hidden-for-now" style="display: none">
            <hr />
            <div class="form-group">
                @Html.LabelFor(model => model.IsSpecial, "Good for both quick AND regular lunches", htmlAttributes: new { @class = "control-label col-md-3" })
                <div class="col-md-9" style="text-align: left">
                    @Html.CheckBoxFor(model => model.IsSpecial, htmlAttributes: new { @class = "form-control left", style = "width: 45px", id = "special" })

                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.MinWeeksBetweenVisits, "Never visit more than once every X weeks", htmlAttributes: new { @class = "control-label col-md-3" })
                <div class="col-md-9">
                    @Html.EditorFor(model => model.MinWeeksBetweenVisits, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.MinWeeksBetweenVisits, "", new { @class = "text-danger" })
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.DaysOfWeek.Monday, "Visit on Mondays", htmlAttributes: new { @class = "control-label col-md-3", id = "special" })
                <div class="col-md-9" style="text-align: left">
                    @Html.CheckBoxFor(model => model.DaysOfWeek.Monday, htmlAttributes: new { @class = "form-control left", style = "width: 45px" })
                </div>
                @Html.LabelFor(model => model.DaysOfWeek.Tuesday, "Visit on Tuesdays", htmlAttributes: new { @class = "control-label col-md-3", id = "special" })
                <div class="col-md-9" style="text-align: left">
                    @Html.CheckBoxFor(model => model.DaysOfWeek.Tuesday, htmlAttributes: new { @class = "form-control left", style = "width: 45px" })
                </div>
                @Html.LabelFor(model => model.DaysOfWeek.Wednesday, "Visit on Wednesdays", htmlAttributes: new { @class = "control-label col-md-3", id = "special" })
                <div class="col-md-9" style="text-align: left">
                    @Html.CheckBoxFor(model => model.DaysOfWeek.Wednesday, htmlAttributes: new { @class = "form-control left", style = "width: 45px" })
                </div>
                @Html.LabelFor(model => model.DaysOfWeek.Thursday, "Visit on Thursdays", htmlAttributes: new { @class = "control-label col-md-3", id = "special" })
                <div class="col-md-9" style="text-align: left">
                    @Html.CheckBoxFor(model => model.DaysOfWeek.Thursday, htmlAttributes: new { @class = "form-control left", style = "width: 45px" })
                </div>
                @Html.LabelFor(model => model.DaysOfWeek.Friday, "Visit on Fridays", htmlAttributes: new { @class = "control-label col-md-3", id = "special" })
                <div class="col-md-9" style="text-align: left">
                    @Html.CheckBoxFor(model => model.DaysOfWeek.Friday, htmlAttributes: new { @class = "form-control left", style = "width: 45px" })
                </div>
            </div>

        </div>
        <hr />
        <div class="form-group">
            <div class="col-md-offset-2 col-md-9">
                <input type="submit" value="Save" class="btn btn-primary" />
                <a href="@Url.Action("Index")" class="btn btn-info">Cancel</a>
            </div>
        </div>
    </div>
}

@section Scripts {
    @if (!Model.IsQuick)
    {
        <script>$('#special').prop('disabled', true);</script>
    }
    @Scripts.Render("~/bundles/jqueryval")
}
